(define (make-account balance password)
  (define (withdraw amount)
    (if (>= balance amount)
        (begin (set! balance (- balance amount))
               balance)
        "Insufficient funds"))
  (define (deposit amount)
    (set! balance (+ balance amount)))
  (let ((passwords (list password)))
    (define (make-joint new-password)
      (set! passwords (cons new-password passwords))
      dispatch)
    (define (dispatch p m)
      (cond ((not (memq p passwords))
             (lambda (amount) (error "Incorrect password")))
            ((eq? m 'withdraw) withdraw)
            ((eq? m 'deposit) deposit)
            ((eq? m 'make-joint) make-joint)
            (else (error "Unkown request -- MAKE-ACCOUNT"
                         m))))
    dispatch))

(define (make-joint account password new-password)
  ((account password 'make-joint) new-password))
